﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pgActivarUsuarios.aspx.cs" Inherits="EGuayas.Web.Usuario.pgActivarUsuarios" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link  href="~/Resources/css/Style.css"  rel="stylesheet" />
    <!-- Load Ext JS --> 
    <script src="../Resources/js/Global.js"></script>
   
</head>
<body>  
    <form id="Form1" runat="server">
        
        <ext:ResourceManager ID="pgIdCategManager" runat="server" />
        <ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout">
            <Items>
                <ext:FormPanel ID="FormPanel1" runat="server" Region="Center" Layout="VBoxLayout"  >
                        <LayoutConfig>
                                <ext:VBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
                             <%-- Hidden almacena IdPageSession  --%>
                             <ext:Hidden Text="" ID="hddIdPageSession" runat="server"></ext:Hidden>
                             <%-- Hidden almacena Id Usuario --%>
                             <ext:Hidden Text="" ID="hddIdPersonaTmp" runat="server"></ext:Hidden>

                             <ext:FormPanel
                                ID     ="frmSettings"
                                runat  ="server" 
                                Title  ="Lista de usuarios Activar/Notificar" 
                                Icon        ="GroupGo"
                                Margins     ="5 5 5 5" 
                                Flex        ="1"
                                Layout      ="FitLayout"
                                BodyBorder  ="0"                          
                                Collapsible ="true">                           
                                <Items>
                                            <ext:GridPanel
                                                ID="gpDocumentosLoadUser"
                                                runat="server"                                           
                                                Height="90">
                                                <Store>
                                                    <ext:Store ID="Store2" runat="server">
                                                        <Model>
                                                            <ext:Model ID="Model2" runat="server" IDProperty="Id">
                                                                <Fields>
                                                                        <ext:ModelField Name="Login" Type="String" />
                                                                        <ext:ModelField Name="FechaCreacion" Type="Date" />                                                                 
                                                                        <ext:ModelField Name="Clave" Type="String" />
                                                                        <ext:ModelField Name="Id" Type="String" />
                                                                        <ext:ModelField Name="Identificacion" Type="String" />
                                                                        <ext:ModelField Name="Nombre" Type="String" />
                                                                        <ext:ModelField Name="Apellido" Type="String" />
                                                                        <ext:ModelField Name="Direccion" Type="String" />
                                                                        <ext:ModelField Name="Email" Type="String" />
                                                                        <ext:ModelField Name="Estado" Type="String" />
                                                                        <ext:ModelField Name="PersonaId" Type="String" />
                                                                        <ext:ModelField Name="RolId" Type="String" />
                                                                        <ext:ModelField Name="ParroquiaId" Type="String" />      
                                                                </Fields>
                                                            </ext:Model>
                                                        </Model>                                      
                                                        <Proxy>
                                                            <ext:PageProxy DirectFn="App.direct.BindData">
                                                                <Reader>
                                                                    <ext:JsonReader></ext:JsonReader>
                                                                </Reader>
                                                            </ext:PageProxy>
                                                        </Proxy>
                                                    </ext:Store>
                                                </Store>
                                                <ColumnModel ID="ColumnModel2" runat="server">
                                                    <Columns>
                                                        <ext:Column  runat="server" Text="Id" DataIndex="Id" Flex="1" Hidden="true"/>
                                                        <ext:Column  runat="server" Text="Nombre" DataIndex="Nombre" Flex="2"/>
                                                        <ext:Column  runat="server" Text="Apellido" DataIndex="Apellido" Flex="2"/> 
                                                        <ext:DateColumn runat="server" Text="Fecha" Width="95" DataIndex="FechaCreacion" Format="dd-m-yy" />
                                                    
                                                        <ext:ImageCommandColumn ID="ImageCommandColumn1" runat="server" Width="80" Text="Estado" Align="Center">
                                                            <Commands>
                                                                 <ext:ImageCommand CommandName="Activar" Icon="UserGo" Text="Activar">
                                                                 </ext:ImageCommand>
                                                                <ext:ImageCommand CommandName="Notificar" Icon="EmailAdd" Text="Notificar">
                                                                  
                                                                </ext:ImageCommand>
                                                            </Commands>
                                                            <PrepareCommand Fn="pgFn.PrepareCommand" />
                                                          
                                                            <Listeners>
                                                                <Command Handler="pgFn.ShowViewDetailPanel(record);" />
                                                            </Listeners>
                                                        </ext:ImageCommandColumn>  
                                                                                                                       
                                                    </Columns>                                                    
                                                </ColumnModel>
                                                           
		                                            <BottomBar>
		                                             <ext:PagingToolbar ID="PagingToolbar1" runat="server">
			                                            <Items>
				                                            <ext:Label ID="Label1" runat="server" Text="Filas por página:" />
				                                            <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
				                                            <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
					                                            <Items>
						                                            <ext:ListItem Text="5" />
						                                            <ext:ListItem Text="10" />
						                                            <ext:ListItem Text="15" />
						                                            <ext:ListItem Text="20" />
						                                            <ext:ListItem Text="25" />
						                                            <ext:ListItem Text="30" />
						                                            <ext:ListItem Text="35" />
						                                            <ext:ListItem Text="40" />
						                                            <ext:ListItem Text="45" />
						                                            <ext:ListItem Text="50" />
					                                            </Items>
					                                            <SelectedItems>
						                                            <ext:ListItem Value="10" />
					                                            </SelectedItems>
					                                            <Listeners>
						                                            <Select Handler="#{gpDocumentosLoadUser}.store.pageSize = parseInt(this.getValue(), 10); #{gpDocumentosLoadUser}.store.reload();" />
					                                            </Listeners>
				                                            </ext:ComboBox>
			                                            </Items>

		                                            </ext:PagingToolbar>
		                                            </BottomBar> 
                                                  <View>
		                                                <ext:GridView ID="GridView2" runat="server" StripeRows="true" />                   
		                                            </View>
                                                  <Features>

                                        <ext:GridFilters runat="server" ID="GridFilters1" Local="true" MenuFilterText="Filtrar por">
                                            <Filters>
                                                <ext:StringFilter DataIndex="Nombre"  EmptyText="Nombre"/>
                                                <ext:StringFilter DataIndex="Apellido" EmptyText="Apellido"/>
                                                <ext:DateFilter DataIndex="FechaCreacion" AfterText="Despues de" BeforeText="Antes de"  OnText="En" >
                                                    <DatePickerOptions runat="server" TodayText="Ahora" />
                                                </ext:DateFilter>                                                            
                                           
                                            </Filters>
                                        </ext:GridFilters>
                             </Features>                                                          
                                            </ext:GridPanel>
                                   </Items>                                  
                            </ext:FormPanel>              
                            <ext:FormPanel
                                ID    ="frmDetail"
                                runat ="server" 
                                Title ="Detalle" 
                                Icon  ="ReportEdit"
                                Margins ="5 5 5 5" 
                                Flex    ="1"
                                Layout  ="FitLayout"
                                BodyBorder  ="0"                                
                                Hidden   ="true">  
                                <TopBar>
                                            <ext:Toolbar ID="Toolbar2" runat="server">
                                                <Items>
                                                  <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                                                    <ext:Button 
                                                        ID    ="btnForm"
                                                        runat ="server" 
                                                        Text  ="Ver Usuarios" 
                                                        Icon  ="ShapeSquareGo"
                                                        OnClientClick="pgFn.ClosePanel();">                                            
                                                        <Listeners>                     
                                                        </Listeners>
                                                    </ext:Button>
                                                  
                                                </Items>
                                            </ext:Toolbar>
                                </TopBar>
                                 <Items>  
                                           <ext:Hidden Text="" ID="hdId"   Name="Id" runat  ="server"></ext:Hidden>
                                           <ext:Hidden Text="" ID="hdRolId"  Name="RolId"  runat   ="server"></ext:Hidden>
                                           <ext:TabPanel ID="TabPanel1" runat="server" Region="Center"  TabPosition="Left" 
                                                EnableTabScroll="true">
                                                <Items> 
                                                    <ext:Panel ID ="tab1FrmDetail" runat="server" Title="Información de Usuario"
                                                     ButtonAlign ="Center" >
                                                            <Loader ID="Loader2"  Url="tabs/pgUndefined.aspx"   Mode="Frame"  AutoLoad="false" Scripts="true" DisableCaching="true" runat="server" >
                                                                <LoadMask ShowMask="true" />
                                                            </Loader>
                                                            <Buttons>
                                                                    <%--
                                                                    <ext:Button ID="btnCancelComentario" runat="server" Text="Comentario" Hidden="true">
                                                                           <Listeners>
                                                                                 <Click Handler="AppGlobalJs.showWin(#{winComentario});" />
                                                                            </Listeners>  
                                                                    </ext:Button> 
                                                                     --%>
                                                                    <ext:Button ID="btnRevisar" runat="server" Text="Activar" Hidden="true" >
                                                                        <DirectEvents>
                                                                            <Click OnEvent="btnRevisar_Click">
                                                                               <ExtraParams>
                                                                                        <ext:Parameter Name="hdId" Value="#{hdId}.getValue()"   Mode="Raw" /> 
                                                                                        <ext:Parameter Name="hdRolId" Value="#{hdRolId}.getValue()"   Mode="Raw" />                              
                                                                               </ExtraParams>	
                                                                                <EventMask ShowMask="True"></EventMask>		    
                                                                            </Click> 
                                                                        </DirectEvents>    
                                                                    </ext:Button>
                                                                    <ext:Button ID="btnNotificar" runat="server" Text="Notificar"  Hidden="true" >
                                                                        <DirectEvents>
                                                                            <Click OnEvent="btnNotificar_Click"  Before="Ext.Msg.wait('Notificación usuario por correo...', 'Notificación');"                                
                                                                                Failure="Ext.Msg.show({ 
                                                                                    title   : 'Error', 
                                                                                    msg     : 'Error', 
                                                                                    minWidth: 200, 
                                                                                    modal   : true, 
                                                                                    icon    : Ext.Msg.ERROR, 
                                                                                    buttons : Ext.Msg.OK 
                                                                                });">
                                                                               <ExtraParams>
                                                                                        <ext:Parameter Name="hdId" Value="#{hdId}.getValue()"   Mode="Raw" /> 
                                                                                        <ext:Parameter Name="hdRolId" Value="#{hdRolId}.getValue()"   Mode="Raw" />                              
                                                                               </ExtraParams>	
                                                                                <EventMask ShowMask="True"></EventMask>		    		    
                                                                            </Click> 
                                                                        </DirectEvents>    
                                                                    </ext:Button>
                                                            </Buttons>
                                                    </ext:Panel>
                                                    </Items>
                                            </ext:TabPanel>                    
                                 </Items>
                           </ext:FormPanel>
                        </Items>
                       
                       <BottomBar>
                         <ext:StatusBar 
                                ID="StatusBar2" 
                                runat="server"
                                StatusAlign="Left">
                                <Items>                                
                                    <ext:ToolbarTextItem ID="ToolbarTextItem1" runat="server" Text="" Cls="ux-bold-text-item"  Margin="15"/>
                                </Items>
                            </ext:StatusBar>
                        </BottomBar>
           </ext:FormPanel>
         </Items>
       </ext:Viewport>
    </form>
    <ext:XScript ID="XScript1" runat="server">
        <script  type="text/javascript">
            var pgFn = new Object();
            pgFn._id = "pnlContentUrlDinamic";
            pgFn.myPanel = null;
            pgFn.getIdContentDinamic = function () {
                return (pgFn._id);
            };
            //Cerrar panel detalles
            pgFn.ClosePanel = function () {
             
                var myPanelContent = App.tab1FrmDetail;
                //Creacion del tab
                if (pgFn.myPanel != null) {
                    myPanelContent.remove(pgFn.getIdContentDinamic(), false);
                    pgFn.myPanel = null;
                }
                App.frmDetail.hide();
                App.frmSettings.show();
               
                App.frmDetail.getForm().reset();
                //  
                App.btnRevisar.enable();
                App.btnNotificar.enable();
                //App.btnCancelComentario.enable();
             
                //App.btnComentarioOk.enable();
               
                App.btnRevisar.hide();
                App.btnNotificar.hide();
               
            };
            pgFn.ActivarUsuarioPanel = function () {
                // window.parent.frames[0].App.frmSettings.hide();//Codigo Inicial
                window.parent.frames[0].App.frmDetail.hide();
                window.parent.frames[0].App.frmSettings.show();
            };
            pgFn.ActivarButtonsPanel = function () {
                App.btnRevisar.hide();
                App.btnNotificar.hide();
            };
            //Mostrar panel detalles
            pgFn.ShowViewDetailPanel = function (record) {
                var myUrl = "pgPromotor.aspx?idPage=" + App.hddIdPageSession.getValue() + "&idx1=" + record.get("PersonaId") + "&idx2=" + record.get("Id");
                //               
                switch (record.get("Estado")) {
                    case "INACTIVO":
                        //App.btnCancelComentario.hide();
                        App.btnRevisar.hide();
                        App.btnNotificar.show();

                        break;
                    case "NOTIFICADO":
                        //App.btnCancelComentario.hide();
                        App.btnRevisar.show();
                        App.btnNotificar.hide();
                        break;
                    default:
                        //App.btnCancelComentario.hide();
                        App.btnRevisar.hide();
                        App.btnNotificar.hide();
                        break;

                }
                //Mostrar/ocultar paneles
                App.hddIdPersonaTmp.setValue(record.get("PersonaId"));
                App.frmSettings.hide();
                App.frmDetail.show();
                //Panel contenedor
                var myPanelContent= App.tab1FrmDetail;                
                pgFn.myPanel = myPanelContent.add(new Ext.Panel({
                   id: pgFn.getIdContentDinamic(),
                   border: false,
                   margins: '5 5 5 0',
                   layout: 'fit',
                   loader:
                    {
                        loadMask:
                            {
                                showMask: true
                            },
                        renderer: "frame",
                        url: myUrl
                    },
                    bodyPadding: 6,
                    closable: false,
                    listeners:{
                        beforeshow:
                            {
                                handler: pgFn.ActivarButtonsPanel()
                            }
                        }
                 }));
                //
                App.frmDetail.getForm().loadRecord(record);
               
            };
            //Mostrar y/o ocultar botones de acuerdo a estado de documento
            pgFn.PrepareCommand = function (grid, command, record, row) {
                if (command.command == 'Activar') {

                    if (record.get("Estado") == 'INACTIVO') {                      
                        command.hidden = false;
                        command.hideMode = 'visibility';
                       
                    }
                    else
                    {
                        command.hidden = true;
                        command.hideMode = 'display'; 
                    }


                }
                if (command.command == 'Notificar') {

                    if (record.get("Estado") == 'NOTIFICADO') {                       
                        command.hidden = false;
                        command.hideMode = 'visibility';
                    }
                    else
                    {
                       command.hidden = true;
                        command.hideMode = 'display';
                    }

                }
               

            };
       </script>
    </ext:XScript>     
</body>


</html>
